package com.guosong.rabbitmq.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitUtils {
    private static ConnectionFactory connectionFactory =new ConnectionFactory();

    static {
        connectionFactory.setHost("192.168.253.15");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("lisi");
        connectionFactory.setPassword("123");
        connectionFactory.setVirtualHost("ac");
    }
    public static Connection getConnection(){
        Connection connection=null;
        Connection connection2 = null;
        try {
            connection = connectionFactory.newConnection();
            return  connection;
        } catch (IOException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        }
        return  null;

    }


}
